<?php
	//begin blog template
	$params = $this->bparams->params;
	$showimage 	= $params->get( 'showimage', 0 );
	$autoresize = intval (trim( $params->get( 'autoresize', 0) ));
	$img_w = intval (trim( $params->get( 'width', 100 ) ));
	$img_h = intval (trim( $params->get( 'height', 100 ) ));
	$img_align	= $params->get( 'align' , 0);
	
	$maxchars =	intval (trim( $params->get( 'maxchars', 200 ) ));
	$introitems =	intval (trim( $params->get( 'introitems', 1 ) ));
	$linkitems = intval (trim( $params->get( 'linkitems', 0 ) ));
	
	$showreadmore = intval (trim( $params->get( 'showreadmore', 0 ) ));
	$showcattitle = intval (trim( $params->get( 'showcattitle', 1 ) ));
  $hiddenClasses 				= 	trim( $params->get( 'hiddenClasses', '' ) );
	$cols = intval (trim( $params->get( 'columns', 2) ));
	
	$secid = $this->secid;
	$contents = $this->contents;
	$themes = $this->themes;
	$news = count($contents);
	if($news < $cols) $cols = $news;
	if (!$cols) return;
	//adjust the cols value
	$width = round(99/$cols,1);
	
	JHTML::stylesheet('',JaNewsHelper::getFile('ja.news.css','components/com_janews/layouts/blog/'.$this->bparams->template.'/assets/','templates/'.$mainframe->getTemplate().'/css/'));
?>

<div id="jazin-wrap">
<div id="jazin" class="clearfix">

<?php
  $c = 0;
	foreach ($contents as $content){
	  $colArr[$c][] = $content;
	  $c = ($c < ($cols - 1)) ? $c + 1 : 0;
	}
			
  $k = 0;
  for ($z = 0; $z < $cols; $z ++) :
	  $cls = $cols==1?'full':($z==0?'left':($z==$cols-1?'right':'center'));
?>
		<div class="jazin-<?php echo $cls;?>" style="width:<?php echo $width;?>%; float:<?php echo $cls;?>">
		<?php /*for ($y = 0; $y < ($news / $cols) && $k<$news; $y ++) :
		  $params->set('blog_theme','');// $themes[$k]);
		  $rows = $contents[$k];
		  if($secid) {
  			include(dirname(__FILE__).'/blog_item.php');
      }
		  $k++;
		endfor; */?>
		
		<?php 
		  foreach ($colArr[$z] as $content):
		  $params->set('blog_theme','');
		  $rows = $content;
		  if($secid) {
  			include(dirname(__FILE__).'/blog_item.php');
      }
		endforeach;?>
		
		</div>
	<?php endfor; ?>
</div>
</div>